package queue

type SliceQueue struct {
	arr []int
	rear int	//队列头
	front int	//队列尾
}

func (q *SliceQueue) IsEmpty() bool {
	if q != nil && q.front != q.rear {
		return false
	}
	return true
}

func (q *SliceQueue) SIze() int {
	return q.rear - q.front
}

func (q *SliceQueue) GetFront() int {
	if q.IsEmpty() {
		panic("q is Empty")
	}
	return q.arr[q.front]
}

func (q *SliceQueue) GetBack() int {
	if q.IsEmpty() {
		panic("q is Empty")
	}
	return q.arr[q.rear - 1]
}

func (q *SliceQueue) Dequeue() int {
	if q.IsEmpty() {
		panic("q is Empty")
	}
	tmp := q.arr[q.rear - 1]
	q.rear--
	q.arr = q.arr[1:]
	return tmp
}

func (q *SliceQueue) Enqueue(d int) {
	q.arr = append(q.arr, d)
	q.rear++
}